package com.xing.mapper;

import com.xing.model.Discuss;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 柠檬有点甜
 * @since 2021-09-18
 */
@Repository
public interface DiscussMapper extends BaseMapper<Discuss> {

    @Select("select m_discuss.*,m_blog.title,m_user.username,m_user.avatar from m_discuss join m_blog on m_blog.id = m_discuss.blog_id join m_user on m_user.id = m_discuss.user_id order by m_discuss.discuss_id desc limit 0,10")
    List<Discuss> selectDiscuss();


    @Select("select m_discuss.*,m_user.username,m_user.avatar from m_discuss join m_blog on m_blog.id = m_discuss.blog_id join m_user on m_user.id = m_discuss.user_id where m_blog.id = #{blogId} order by m_discuss.discuss_id desc limit #{pageint},5")
    List<Discuss> selectDiscussById(@Param("blogId") int blogId, @Param("pageint")int pageint);

}
